package com.apes.scm.masterdata.frame.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import com.apes.framework.jpa.Model;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 联系人
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Contacts.CONST_TABLE_NAME)
public class Contacts extends Model {
    public static final String CONST_TABLE_NAME = "mas_contacts";


    @Id
    @Column(name = "id", length = 30)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "联系人")
    @Comment("编码")
    private String id;

    @Name
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "contact_id" ,referencedColumnName = "id")
    @Comment("操作员")
    private PartyRole contact;

    @Column(name = "mobile_number", length = 32)
    @Comment("手机号")
    private String mobileNumber;

    @Column(name = "store_id", length = 32)
    @Comment("部门id")
    private String storeId;//部门编码

    @Column(name = "note", length = 250)
    @Comment("备注")
    private String note;


}
